package cz.proks.schoolpupilbook.gae.restlet;

import static cz.proks.schoolpupilbook.shared.restlet.RestMapping.*;
import static cz.proks.schoolpupilbook.shared.restlet.RestMapping.REST_ROUTE_COURSE;
import static cz.proks.schoolpupilbook.shared.restlet.RestMapping.REST_ROUTE_COURSE_BASE;
import static cz.proks.schoolpupilbook.shared.restlet.RestMapping.REST_ROUTE_LIST_NONQUERY;
import static cz.proks.schoolpupilbook.shared.restlet.RestMapping.REST_ROUTE_LIST_QUERY;
import static cz.proks.schoolpupilbook.shared.restlet.RestMapping.REST_ROUTE_MARK;
import static cz.proks.schoolpupilbook.shared.restlet.RestMapping.REST_ROUTE_MARK_BASE;
import static cz.proks.schoolpupilbook.shared.restlet.RestMapping.REST_ROUTE_USER;
import static cz.proks.schoolpupilbook.shared.restlet.RestMapping.REST_ROUTE_USER_BASE;
import static cz.proks.schoolpupilbook.shared.restlet.RestMapping.REST_ROUTE_USER_COURSE_RELATION;
import static cz.proks.schoolpupilbook.shared.restlet.RestMapping.REST_ROUTE_USER_COURSE_RELATION_BASE;
import static cz.proks.schoolpupilbook.shared.restlet.RestMapping.REST_ROUTE_USER_RELATION;
import static cz.proks.schoolpupilbook.shared.restlet.RestMapping.REST_ROUTE_USER_RELATION_BASE;

import org.restlet.Application;
import org.restlet.Restlet;
import org.restlet.resource.Directory;
import org.restlet.routing.Router;

import cz.proks.schoolpupilbook.gae.restlet.resource.CourseServerResource;
import cz.proks.schoolpupilbook.gae.restlet.resource.ListServerResource;
import cz.proks.schoolpupilbook.gae.restlet.resource.MarkCommentServerResource;
import cz.proks.schoolpupilbook.gae.restlet.resource.MarkServerResource;
import cz.proks.schoolpupilbook.gae.restlet.resource.UserCourseRelationServerResource;
import cz.proks.schoolpupilbook.gae.restlet.resource.UserRelationServerResource;
import cz.proks.schoolpupilbook.gae.restlet.resource.UserServerResource;

public class RestletApplication extends Application {
	

	@Override
	public Restlet createInboundRoot() {
		Router router = new Router(getContext());		
		
		// attach default
		router.attachDefault(new Directory(getContext(), "war:///"));
					
		// attach context		
		router.attach(REST_ROUTE_USER_BASE, UserServerResource.class);
		router.attach(REST_ROUTE_USER, UserServerResource.class);		
		router.attach(REST_ROUTE_COURSE_BASE, CourseServerResource.class);
		router.attach(REST_ROUTE_COURSE, CourseServerResource.class);
		router.attach(REST_ROUTE_MARK_BASE, MarkServerResource.class);
		router.attach(REST_ROUTE_MARK, MarkServerResource.class);
		router.attach(REST_ROUTE_USER_COURSE_RELATION_BASE, UserCourseRelationServerResource.class);
		router.attach(REST_ROUTE_USER_COURSE_RELATION, UserCourseRelationServerResource.class);
		router.attach(REST_ROUTE_USER_RELATION_BASE, UserRelationServerResource.class);
		router.attach(REST_ROUTE_USER_RELATION, UserRelationServerResource.class);
		router.attach(REST_ROUTE_MARK_COMMENT_BASE, MarkCommentServerResource.class);
		router.attach(REST_ROUTE_MARK_COMMENT, MarkCommentServerResource.class);
		router.attach(REST_ROUTE_LIST_QUERY, ListServerResource.class);				
		router.attach(REST_ROUTE_LIST_NONQUERY, ListServerResource.class);
		
		return router;
	}	
}
